<template>
    <base-breadcrumb :breadcrumb="!isAudit">
        <template>
            <a-card class="mb20">
                <a-row :gutter="24">
                    <a-col :md="18">
                        <a-steps progress-dot :current="3" size="small">
                            <a-step title="步骤一" description="基本信息填写" />
                            <a-step title="步骤二" description="资料汇总" />
                            <a-step title="完成" description="上传签字盖章后的资料" />
                        </a-steps>
                    </a-col>
                    <!-- <a-col :md="6"> -->
                    <!-- <a-button @click="showModal">打印：劳务（专业）分包报量审核报告</a-button> -->
                    <!-- <a-modal title='baobiao' :visible="visible" @cancel="handleCancel" closable='false'>
              <img class="img-box" src='https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1597731679898&di=7e2070191e8a1b04de3625a0b52927d5&imgtype=0&src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201504%2F04%2F20150404H5058_kaZrB.jpeg' />
            </a-modal>-->
                    <!-- </a-col> -->
                </a-row>

                <titleName title="基本信息" class="title-style"></titleName>
                <a-form-model
                    ref="ruleForm"
                    :model="form"
                    :hideRequiredMark="true"
                    :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                    :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                >
                    <a-row :gutter="24">
                        <a-col :md="8" :sm="8">
                            <a-form-model-item label="所属分公司：">
                                <BaseInput disabled placeholder="请选择" v-model="form.branchComName"></BaseInput>
                            </a-form-model-item>
                        </a-col>
                        <a-col :md="8" :sm="8">
                            <a-form-model-item label="所属项目：">
                                <BaseInput disabled placeholder="请选择" v-model="form.projectName"></BaseInput>
                            </a-form-model-item>
                        </a-col>
                        <a-col :md="8" :sm="8">
                            <a-form-model-item label="分包商名称：">
                                <BaseInput disabled placeholder="请选择" v-model="form.subContractorName"></BaseInput>
                            </a-form-model-item>
                        </a-col>
                        <a-col :md="8" :sm="8">
                            <a-form-model-item label="名称：" prop="name">
                                <BaseInput disabled placeholder="请输入名称" v-model="form.name" />
                            </a-form-model-item>
                        </a-col>
                        <a-col :md="8" :sm="8">
                            <a-form-model-item label="截止2016年4月30日累计含税金额(元)：" prop="participants">
                                <BaseInput disabled placeholder="请输入名称" v-model="form.yearAmount" />
                            </a-form-model-item>
                        </a-col>
                        <a-col :md="8" :sm="8">
                            <a-form-model-item label="计量月份" prop="measureMonth">
                                <BaseInput disabled placeholder="请输入" v-model="form.measureMonth" />
                            </a-form-model-item>
                        </a-col>
                        <a-col :md="24" :sm="24">
                            <a-form-model-item label="施工范围：" prop="name">
                                <BaseTextarea disabled placeholder="请输入" v-model="form.constructionRange" />
                            </a-form-model-item>
                        </a-col>
                        <a-col :md="16" :sm="16">
                            <a-form-model-item label="附件上传">
                                <l-table
                                    v-if="isUpdate"
                                    @fileArrysData="fileArrysData"
                                    :uploadArrys="form.reviewFileInfoVOList"
                                    businessCode="BM06"
                                ></l-table>
                            </a-form-model-item>
                        </a-col>
                    </a-row>
                </a-form-model>
            </a-card>

            <div class="tool-btns mb20 page-btn-right-top">
                <!-- <a-button
                    :loading="loading.DELETE"
                    type="danger"
                    v-if="form.auditStatus == 'DRAFT'"
                    @click="deleteDraft"
                    >删除草稿</a-button
                >
                <a-button :loading="loading.DRAFT" type="primary" @click="submitForm('DRAFT')">保存草稿</a-button> -->
                <a-button :loading="loading.SUBMITTED" type="primary" @click="submitForm('SUBMITTED')">提交</a-button>
                <a-button type="primary" @click="closeForm">关闭</a-button>
            </div>
        </template>
    </base-breadcrumb>
</template>
<script>
import { getStepOneDetail, getTable, addStepFour, updateStepFour, delStepFour } from '@/api/businessAffairs/sml'
import { isAttachment } from '@/utils/util'
export default {
    name:'a'+Date.now(),
    data() {
        return {
            loading: {
                DELETE: false,
                DRAFT: false,
                SUBMITTED: false,
            },
            isUpdate: true,
            form: {},
        }
    },

    mounted() {
        if (this.$route.query.id) {
            this.id = this.$route.query.id
            console.log(this.id)
            this.isUpdate = false
            this.getStepOneDetail()
        }
    },
    methods: {
        // 关闭表单
        closeForm() {
            this.$multiTab.close(this.$route.fullpath)
        },
        fileArrysData: function (val) {
            this.form.reviewFileInfoVOList = val

            console.log(val)
        },
        // 删除草稿
        deleteDraft() {
            let that = this
            this.$confirm({
                title: '温馨提示',
                content: '确定是否删除数据？',
                okText: '确认',
                okType: 'danger',
                cancelText: '取消',
                onOk() {
                    return delStepFour({ id: that.form.id }).then((res) => {
                        if (res.code == '200') {
                            that.$message.success('操作成功')
                            that.closeForm()
                        }
                    })
                },
                onCancel() {},
            })
        },
        showModal() {},
        getStepOneDetail() {
            let params = {
                id: this.id,
            }
            getStepOneDetail(params).then((res) => {
                console.log(res)
                this.isUpdate = true
                this.form = res.data
            })
        },
        // 提交表单
        submitForm(auditStatus) {
            this.form.measureId = this.id
            console.log(this.form.auditStatus)
            this.form.fileIdList = this.form.fileInfoVOList
            if (isAttachment(this, auditStatus, this.form.reviewFileInfoVOList)) return
            this.loading[auditStatus] = true

            if (this.form.auditStatus == null) {
                this.form.auditStatus = auditStatus
                addStepFour(this.form).then((res) => {
                    this.loading[auditStatus] = false
                    this.$message.success('操作成功')
                    this.closeForm()
                })
            } else {
                this.form.auditStatus = auditStatus

                updateStepFour(this.form).then((res) => {
                    this.loading[auditStatus] = false
                    this.$message.success('操作成功')
                    this.closeForm()
                })
            }
        },
    },
}
</script>

<style lang="less" scoped>
@deep: ~'>>>';
.tool-btns {
    display: flex;
    justify-content: flex-end;
    @{deep} .ant-btn + .ant-btn {
        margin-left: 12px;
    }
}
.step-text {
    .ant-steps-item-title {
        width: 168px;
    }
}
.check-box {
    .ant-checkbox-group {
        margin-top: 1.5%;
        display: flex;
        justify-content: space-between;
    }
    .ant-checkbox-group-item {
        position: static !important;
    }
}
.radio-box {
    .ant-radio-wrapper {
        position: static !important;
    }
    .ant-radio-group {
        margin-top: 3% !important;
        display: flex;
    }
}
.img-box {
    width: 500px;
    height: 800px;
    text-align: center;
}
</style>